package com.sky.controller.admin;


import com.sky.result.Result;
import com.sky.utils.AliyunOss;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
@RequestMapping("/admin/common")
public class UploadController {
    @Autowired
    private AliyunOss aliyunOss;
    @PostMapping("/upload")

    public Result upload(MultipartFile file) throws Exception {
        log.info("上传文件:{}", file);
        String url = aliyunOss.upload(file.getBytes(), file.getOriginalFilename());
        log.info("上传文件OSS，url:{}", url);
        return Result.success(url);
    }
}
